home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / clang / ebksrc.zip / PICKFILE.HPP < prev    next >
C/C++ Source or Header  |  1991-07-30  |  2KB  |  100 lines

  1. /*
  2.  
  3.     pickfile.hpp
  4.     7-30-91
  5.     Directory PickList
  6.  
  7.     Copyright 1991
  8.     John W. Small
  9.     All rights reserved
  10.  
  11.     Licensed users of FlexList are free to use and
  12.     modify this tool for use in their programs.
  13.  
  14.  
  15.     PSW / Power SoftWare
  16.     P.O. Box 10072
  17.     McLean, Virginia 22102 8072 USA
  18.  
  19.     Voice: (703) 759-3838
  20.     CIS: 73757,2233
  21.  
  22. */
  23.  
  24. #ifndef PICKFILE_HPP
  25. #define PICKFILE_HPP
  26.  
  27. #include <dos.h>
  28. #include <dir.h>
  29. #ifndef PICKLIST_HPP
  30. #include <picklist.hpp>
  31. #endif
  32.  
  33.  
  34. #define MAX_ATTRIB_STR  7
  35.  
  36. typedef  struct  {
  37.     int tag;
  38.     char  attrib, attribStr[MAX_ATTRIB_STR];
  39.     unsigned ftime;
  40.     unsigned fdate;
  41.     long  fsize;
  42.     int fnameLen, extLen;
  43.     char name[13];
  44.     char entry[45];
  45. } DirEntry, *DirE;
  46. #define DirE0 ((DirE) 0)
  47.  
  48.  
  49. #define PF_WIDTH 39
  50. #define PF_MASK  " Pick File Mask "
  51.  
  52. class PickFile : PickListWindow {
  53.     static char path[], auxpath[];
  54.     static char drive[], dir[], file[], ext[];
  55.     char mask[MAXPATH];
  56.     int mattrib;
  57.     static int DEcompare(const DirE DE1, const DirE DE2);
  58.     int DEload(const char *pathname, int fattrib);
  59.     char *DEpathname(const DirE DE);
  60.     char *fattribStr(char *attribStr, char attrib);
  61.     virtual int idle(int c);
  62.     #pragma argsused
  63.     virtual void displayLine(void * D, int lineLen,
  64.             int cursor)
  65.         { cprintf("%-*.*s",lineLen,lineLen,
  66.             ((DirE)D)->entry); }
  67.     virtual int xcursor(void * D, const char *prefix,
  68.         int pfLen);
  69.     virtual int  match(char *pf, void * D)
  70.     {
  71.         return !strncmpi(pf,((DirE)D)->name,
  72.             strlen(pf));
  73.     }
  74.     virtual int doIt(void * D);
  75.     virtual void dressWindow()
  76.         { putTitle(mask); }
  77.     virtual unsigned paneWidth() { return PF_WIDTH; }
  78. public:
  79.     void setPalette(PalettE PLP = PalettE0,
  80.         PalettE TWP = PalettE0)
  81.     {
  82.         PickList::setPalette(PLP);
  83.         TextWindow::setPalette(TWP);
  84.     }
  85.     PickFile() : PickListWindow(0,PalettE0,PalettE0,
  86.         sizeof(DirEntry),FLmaxMaxNodes,
  87.         FLcomparE(PickFile::DEcompare)) {}
  88.     unsigned choose(const char *pathname = (char *)0,
  89.         int fattrib = FA_DIREC,
  90.         const char *defaultExt = ".*");
  91.     char * choice()
  92.     {
  93.         return DEpathname((DirE)PickList::choice());
  94.     }
  95. };
  96. typedef PickFile * PickF;
  97. #define PickF0 ((PickF)0)
  98.  
  99. #endif
  100.